package com.bosssoft.hr.javase;

import java.io.Serializable;
import java.util.Objects;

/**
 * @Description: 用户类
 * @Author: wengyu
 * @CreateTime: 2022/05/12 15:38
 */
public class User implements Serializable,Comparable<User>{
    private static final long serialVersionUID = 190512204190251207L;

    private Integer id;
    private String name;

    public User() {
    }

    public User(Integer id, String name) {
        this.id = id;
        this.name = name;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        User user = (User) o;
        return Objects.equals(id, user.id) && Objects.equals(name, user.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name);
    }

    @Override
    public int compareTo(User user) {
        if(this.id > user.getId()) {
            return 1;
        }else if(this.id.equals(user.getId())) {
            return 0 ;
        }else {
            return -1;
        }
    }
}
